    /*
* @Author: obsidian
* @Date:   2016-03-01 10:49:08
* @Last Modified by:   obsidian
* @Last Modified time: 2016-04-22 09:05:26
*/

#include "menu_brake.h"
#include "../lcd_global.h"
#include "../lcd.h"
#include "module/brake/brake.h"
static void menu_brake_init(void *parg);

struct Item brake_i[MAX_ITEM_NUM] = 
{
    //ctx               id  flag   isint color int float pos
    {.ctx = "ccr",      .id = 1,  .ctx_len = 4,  .flag = FILE,  .value_type = INTEGER, .p_value = 0,                          .func_enter = nop, .func_exec = input,  nop,    nop},
    {.ctx = "midvl",    .id = 2,  .ctx_len = 5,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&brake.midvalue0,    .func_enter = nop, .func_exec = input,  nop,    nop},    
    {.ctx = "limit",    .id = 3,  .ctx_len = 5,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&brake.limit,    .func_enter = nop, .func_exec = input,  nop,    nop},    
    {.ctx = "ratio",    .id = 4,  .ctx_len = 5,  .flag = FILE,  .value_type = FLOAT,   .p_value = (void *)&brake.ratio,       .func_enter = nop, .func_exec = input,  nop,    nop},    
    {.ctx = "sec",      .id = 5,  .ctx_len = 4,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&brake.second,      .func_enter = nop, .func_exec = input,  nop,    nop},
    {.ctx = "status",   .id = 6,  .ctx_len = 6,  .flag = FILE,  .value_type = INTEGER, .p_value = (void *)&brake.status,      .func_enter = nop, .func_exec = input,  nop,    nop},
};

struct Node brake_n = 
{
    .itemnum        =   0,//sizeof(brake_i) / sizeof(brake_i[0]),
    .page_num       =   0,//(unsigned short)sizeof(brake_i) / sizeof(brake_i[0])/PAGE_SIZE,
    .page_index     =   0,
    .node_id        =   1,
    .p_item         =   brake_i,
    .position       =   {0, 0},
    .parent         =   &control_n,
    .child          =   {0},
    .init           =   menu_brake_init
};

static void menu_brake_init(void *parg)
{
    unsigned char i = 0;
    for(i = 0;i < MAX_ITEM_NUM;i ++)
    {
        if(brake_i[i].ctx[0] == 0){break;}
        brake_n.itemnum ++;
    }
    brake_n.page_num = brake_n.itemnum / PAGE_SIZE;

    brake_n.p_item[0].p_value = (void *)&TIM4->CCR3;
    brake_n.save = brake.save;
}
